package com.jacken.mars;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootVersion;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.core.env.Environment;

import javax.annotation.Resource;


@SpringBootApplication
@MapperScan("com.jacken.mars.mapper")
@Slf4j
public class MarsApplication implements ApplicationRunner {

    @Resource
    private Environment env;

    public static void main(String[] args) {
        SpringApplication.run(MarsApplication.class, args);
    }


    @Override
    public void run(ApplicationArguments args) {
        log.debug("Let's inspect the beans provided by Spring Boot:");
        String version = SpringBootVersion.getVersion();
        int cpuNum = Runtime.getRuntime().availableProcessors();
        log.info(String.format("\n----------------------------------------------------------\n\t" +
                        "Application '%s' is running! \n\t" +
                        "The project Access URL: http://localhost:%s\n\t" +
                        "The following profiles are active: %s\n" +
                        "\tThe project springboot version: %s\n" +
                        "\tThe machine cpu: %s\n" +
                        "----------------------------------------------------------",
                env.getProperty("spring.application.name"),
                env.getProperty("server.port"),
                env.getProperty("spring.profiles.active"), version, cpuNum));


    }

}
